class Main extends React.Component {
    constructor(props) {
  super(props);
  this.state = {
    list:[],
    name:'',
    path:'',
    id:0,
  };
}       

componentDidMount() {
    let UE = window.UE,that=this
    let ueditor = UE.getEditor('ueditor', {
        autoHeightEnabled: true,
        autoFloatEnabled: true
    });
    ueditor.addListener("ready", function () {
        that.setState({ ueditor }, () => {
            that.freshlist()   
        });
    }, 2);
    }
freshlist(){    
let that = this;
getsetting(res=>{
    if(res.issuccess==1){
        let {ueditor}=that.state
        ueditor.setContent(that.replaceraw(decodeURIComponent(res.data.partner)))
    }
})
}
replaceraw(content) {
    return content.replace('rgb(', 'rgb').replace(new RegExp('rgb', 'g'), "rgb(");
}

submit(){
    let {ueditor}=this.state,err = '',html = ueditor.getContent();
    if (!ueditor.hasContents()) err = '内容不能为空';
    if(err!='') {
        alert(err)
        return;
    }
    let partner=this.replaceraw(encodeURIComponent(html))
    setpartner(partner,res=>{
        if(res.issuccess==1){
            alert('修改成功')
            this.freshlist()
        }
    })
  // window.location.href = "./addrole.html";
}
// add(){
//     //  $('#modalOne').modal('toggle');
//    // window.location.href = "./addrole.html";
// }
     render() {
        let{listitem,name,path} = this.state;

            return(
                <div className="breadLinebox">
                <div className='content_wrap panel-default content_wrap'>
                   <div className="breadLine">
                        <div className="img">
                            {/* <img src={Constant.LEFTMENU_ORDER} /> */}
                            当前位置 > 成为合伙人
                        </div>
                    </div>
                   <div className="content">
                        <div>
                        <textarea id={'ueditor'} style={{ height: "70vh"}} ></textarea>
                        </div>
               
                        <div className="submitbox">
                        <button type="button" onClick={this.submit.bind(this)} className="submitbutton">保存</button>
                        </div>
                   </div>
                </div>
                </div>
                
                
            )

            
        }
    }





ReactDOM.render(
    <div>
        <TopLine/>
        <div id='body'>
            <LeftMenu code='partner' />
            <Main/>
        </div>
        </div>
            // <Barrage/>
,$('.container')[0]
)